package app.server.project.main.service.dto.solanainfo;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
@AllArgsConstructor
public class InfoReq {
    private String jsonrpc;
    private String id;
    private String method;
    private List<Object> params;

    public static InfoReq ofCurrentSlot() {
        var currentSlot = CurrentSlotDto.of("finalized");
        List<Object> params = List.of(currentSlot);
        return new InfoReq("2.0", "1", "getSlot", params);
    }

    public static InfoReq ofGetBlock(long slot) {
        List<Object> params = new ArrayList<>();
        params.add(slot);
        var slotDto = SlotDto.of("finalized", "none", false);
        params.add(slotDto);
        return new InfoReq("2.0", "1", "getBlock", params);
    }
}
